#pragma once
#include<sys/types.h>
#include<sys/socket.h>
#include<unistd.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<iostream>
using namespace std;
class InetAddr
{
private:
    void ToHost()
    {
        _port = ntohs(_addr.sin_port);
        _ip = inet_ntoa(_addr.sin_addr);
    }
public:
    InetAddr(const struct sockaddr_in& addr):_addr(addr)
    {
        ToHost();
    }
    InetAddr() = default;
    string Ip() { return _ip; }
    uint16_t Port() { return _port; }

private:
    string _ip;
    uint16_t _port;
    struct sockaddr_in _addr;
};
